<template>
  <div class="dialog-form">
    <el-form :model="form" label-width="100px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="操作模块：">{{ form.title }} / {{ typeFormat(form) }}</el-form-item>
          <el-form-item
            label="登录信息："
          >{{ form.operName }} / {{ form.operIp }} / {{ form.operLocation }}</el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="请求地址：">{{ form.operUrl }}</el-form-item>
          <el-form-item label="请求方式：">{{ form.requestMethod }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="操作方法：">{{ form.method }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="请求参数：">{{ form.operParam }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="返回参数：">{{ form.jsonResult }}</el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="操作状态：">
            <div v-if="form.status === 0">正常</div>
            <div v-else-if="form.status === 1">失败</div>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="消耗时间：">{{ form.costTime }}毫秒</el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="操作时间：">{{ parseTime(form.operTime) }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="异常信息：" v-if="form.status === 1">{{ form.errorMsg }}</el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div class="dialog-footer">
      <el-button @click="onCancel">关闭</el-button>
    </div>
  </div>
</template>

<script setup>
const { proxy } = getCurrentInstance()
const { sys_oper_type } = proxy.useDict("sys_oper_type")
const emits = defineEmits(['cancel'])

const form = ref({})

const pageInit = (row) => {
  form.value = row
}

/** 操作日志类型字典翻译 */
function typeFormat(row, column) {
  return proxy.selectDictLabel(sys_oper_type.value, row.businessType);
}

const onCancel = () => {
  emits('cancel')
}

defineExpose({
  pageInit
})

</script>

<style lang="scss" scoped>

</style>